/**
 * 
 */

var start=false;
var startx=0,starty=0;
var ctx;
function deawinginit()
{
	document.getElementById('canvas').onmousemove=chk;
	document.getElementById('canvas').onmouseup=set;
	ctx=document.getElementById('canvas').getContext('2d');
}
function set(ev)
{
	var lc;
	var lw;
	start=!start;
	startx=ev.x;
	starty=ev.y;
	//선그리기
	if(start)
	{
		ctx.beginPath();
		ctx.moveTo(startx, starty);
		
		lc=document.getElementById('lineColor');
		lw=document.getElementById('lineWidth');
		ctx.strokeStyle=lc.value;
		ctx.lineWidth=lw.value;
	}
	else
	{
		ctx.closePath();
	}
}

function chk(ev)
{
	var d = document.getElementById('result');
	var x=ev.x;
	var y=ev.y;
	d.innerHTML='x='+x+', y='+y;
	if(start)
	{
		ctx.lineTo(x,y);
		ctx.stroke();
	}
}
